package com.lifeng.shop.lifengshop.controller;

import com.lifeng.shop.lifengshop.common.R;
import com.lifeng.shop.lifengshop.mapper.CategoryMapper;

import com.lifeng.shop.lifengshop.mapper.ProductMapper;
import com.lifeng.shop.lifengshop.servies.ProductServies;
import com.lifeng.shop.lifengshop.servies.SearchServies;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Fusion
 * @Date:2021/8/10 10:17
 **/
@RestController
@CrossOrigin
@RequestMapping("/Search")
public class SearchController {
    @Autowired
    private SearchServies searchServies;
    @Autowired
    private ProductServies productServies;

    @RequestMapping("/Bytid")
    public R getCate(int tid) {
        return new R(200, "访问成功！", searchServies.selectAllShop(tid));
    }

    @RequestMapping("/Bytname")
    public R getCateintroduce(String typename) {
        return new R(200, "访问成功", searchServies.selectLikeConcatByTypeName(typename));
    }

    @RequestMapping("/Byfilterlist")
    public R getProduct(String[] filterlist,int tid) {
        return new R(200, "访问成功", productServies.selectAllFilter(filterlist,tid));
    }

    @RequestMapping("/selectBygname")
    public R getProductByname(String gname) {
        return new R(200, "访问成功", searchServies.selectAllBygname(gname));
    }

}
